{extend name="index_base" /} {block name="seo"}
<title>发布帖子 - {$site_config['site_title']} - {$site_config['seo_title']}</title>
<meta name="keywords" content="{$site_config['seo_keyword']}">
<meta name="description" content="{$site_config['seo_description']}"> {/block} {block name="css"}
{/block} {block name="body"}
<div class="layui-container fly-marginTop">
    <div class="fly-panel" pad20="" style="padding-top: 5px;">
        <div class="layui-tab layui-tab-brief" lay-filter="user">
            <ul class="layui-tab-title">
                <li class="layui-this">发表新帖（BBS）</li>

            </ul>
            <div class="layui-form layui-form-pane" style="padding: 20px 0;">

                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">板块</label>
                        <div class="layui-input-block">
                            <select name="tid">
                            <option value="0">请选择版块</option>
                            {volist name="tptc" id="vo"}
                            <option {if condition="$cid eq $vo['id']"}selected="selected"{/if} value="{$vo.id}" >{$vo.name}</option>
                            {/volist}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_title" class="layui-form-label">标题</label>
                    <div class="layui-input-block">
                        <input type="text" name="title" required lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
 {:hook('agencyadd')}
                <div class="layui-form-item layui-form-text">
                  
         
						<textarea id="layeditDemo" lay-verify="content" name="content"></textarea>
                </div>
			 {:hook('addVideo')}	
                <div class="layui-form-item">
                    <label for="L_title" class="layui-form-label">浏览方式</label>

                    <div class="layui-input-block">
                        <input type="radio" name="viewtype" lay-filter="linktype" value="0" title="自由浏览" checked/>
                        <input type="radio" name="viewtype" lay-filter="linktype" value="1" title="付费浏览">
                        <input type="radio" name="viewtype" lay-filter="linktype" value="2" title="回复可见">
                    </div>

                </div>

                <div class="layui-form-item" id="viewscore" style="display:none">
                    <label for="L_title" class="layui-form-label">付费积分</label>
                    <div class="layui-input-inline">
                        <input type="number" style="width:100px;text-align:center" name="fee" value="1" min="1" autocomplete="off" class="layui-input">
                    </div>
                </div>
                {:hook('attachlinkadd')}
                <div class="layui-form-item">
                    <button class="layui-btn" lay-submit="" lay-filter="forum_add">立即发布</button>
                </div>

            </div>
        </div>
    </div>
</div>
{/block} {block name="script"}
<script src="__PUBLIC__/plugins/ace/ace.js"></script>
<script>
    layui.use(['layedit', 'layer', 'form'], function () {
            var $ = layui.jquery;
            var form = layui.form;
            var layedit = layui.layedit;
            layedit.set({
                //暴露layupload参数设置接口 --详细查看layupload参数说明
                uploadImage: {
                    url: '{:url("index/upload/upimage")}',
                    accept: 'image',
                    acceptMime: 'image/*',
                    exts: 'jpg|png|gif|bmp|jpeg',
                    size: '10240'
                }, calldel: {
                    url: '/Attachment/DeleteFile'
                }
                //开发者模式 --默认为false
                , devmode: true
                //插入代码设置
                , codeConfig: {
                    hide: true,  //是否显示编码语言选择框
                    default: 'javascript' //hide为true时的默认语言格式
                }
                , tool: [
                    'code', 'strong', 'italic', 'underline', 'del', 'addhr', '|', 'fontFomatt', 'colorpicker', 'face'
                    , '|', 'left', 'center', 'right', '|', 'link', 'unlink', 'image_alt', 'anchors'
               
                ]
                , height: '90%'
            });
            var ieditor = layedit.build('layeditDemo');
        form.verify({
                    content: function(value) { 
                        return layedit.sync(ieditor);
                        }
         });
        form.on('radio(linktype)', function(data) {
            if (data.value == 1) {
                $("#viewscore").show();
            } else {
                $("#viewscore").hide();
            } //被点击的radio的value值 
        });
        form.on('submit(forum_add)', function(data) {
            loading = layer.load(2, {
                shade: [0.2, '#000']
            });
            var param = data.field;
            $.post("{:url('bbs/forum/add')}", param, function(data) {

                if (data.code == 200) {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 1,
                        time: 1000
                    }, function() {
                        location.href = "{:url('bbs/index/index')}";
                    });
                } else {
                    layer.close(loading);
                    layer.msg(data.msg, {
                        icon: 2,
                        anim: 6,
                        time: 1000
                    });
                }
            });
            return false;
        });
    })
</script>
{/block}